﻿using System;
using System.Collections.Generic;
using System.Text;
using Watchdog.Bll.Factory;

namespace Watchdog.Bll.Base {

    public partial class AssemblyFileBase {

        #region [ Local variables ]
        Facade.AssemblyFile intdata;
        #endregion

        #region [ Constructor(s) ]
        internal AssemblyFileBase () {
            intdata = new Watchdog.Facade.AssemblyFile ();
        }
        internal AssemblyFileBase (Facade.AssemblyFile assemblyfile) : base () {
            intdata = assemblyfile;
        }
        #endregion

        #region [ Field Properties ]
        public int Id {
            get { return intdata.Id; }
        }
        public virtual int Definition {
            get { return intdata.Definition; }
            set { intdata.Definition = value; }
        }
        public virtual string AssemblyName {
            get { return intdata.AssemblyName; }
            set { intdata.AssemblyName = value; }
        }
        public virtual object Release {
            get { return intdata.Release; }
            set { intdata.Release = value; }
        }
        public virtual object Debug {
            get { return intdata.Debug; }
            set { intdata.Debug = value; }
        }
		#endregion
		
        #region [ Data Methods ]
        public void Update () {
            if (Id == -1)
                AssemblyFileFactory.Insert ( this );
            else
                AssemblyFileFactory.Update ( this );
        }

        public void Delete () {
            AssemblyFileFactory.Delete ( this );
        }
        #endregion

		#region [ Many to many relations native type ]

		#endregion

		#region [ Add & Remove methods for many to many relations native type ]

		#endregion
		
        internal Facade.AssemblyFile IntData {
            get { return intdata; }
            set { intdata = value; }
        }

        #region [ Equality ]
        public override int GetHashCode () {
            return Id;
        }
        public static bool operator == ( AssemblyFileBase lt1, AssemblyFileBase lt2 ) {
            if (System.Object.ReferenceEquals ( lt1, lt2 ))
                return true;

            if ((object)lt1 == null || (object)lt2 == null)
                return false;
            return lt1.Equals ( lt2 );
        }
        public static bool operator != ( AssemblyFileBase lt1, AssemblyFileBase lt2 ) {
            if (lt1 == null || lt2 == null)
                return false;
            return !(lt1 == lt2);
        }

        public override bool Equals ( object obj ) {
            if (!(obj is AssemblyFileBase))
                return false;
            return (this.CompareTo ( obj ) == 0);
        }

        private int CompareTo ( object obj ) {
            if (!(obj is AssemblyFileBase)) {
                throw new ArgumentException ( "A 'AssemblyFileBase' object is required for comparison." );
            }
            return this.Id.CompareTo ( ((AssemblyFileBase)obj).Id );
        }
        #endregion

	}
}
